{% extends "admin/base.html" %}
{% block hscript %}
<script type="text/javascript" src="themes/{{site.theme}}/style/jquery.min.js"></script>
{% endblock %}
{% block nav %}
			<a href="?a=Page&d=create">Write page</a>
{% endblock %}
 {% block content %}
   <div class="wrap">

<div class="clear"></div>

	   <div class="tablenav">
		  <div class="alignright">
	{% if pager.prev %}
			<div class="alignleft" ><a href="?a=Page&page={{ pager.prev}}">&laquo; prev</a></div>
			{% endif %}

			{% if pager.next %}
			<div class="alignright"><a href="?a=Page&page={{ pager.next }}">next &raquo;</a></div>
			  {% endif %}
			  <div class="alignright" style="padding:0px 10px;">Page {{ pager.index }}/{{pager.count}}</div>
			  </div>

		<br class="clear"/>
	   </div>
	  <br class="clear"/>

	   <table class="widefat">
		<thead>
			<tr>
			<th></th><th>Date</th><th>Title</th><th>Status</th><th>Edit</th></tr>
			</thead>
			<tbody>
            {% for page in pages %}
		<tr valign="middle" id="page-{{page.id}}">
							<td>{{loop.counter}}</td>
                           <td>{{page.date|date:"HH:mm yyyy-MM-dd"}}</td>
                           <td><strong><a class="row-title" title='Edit "{{page.title}}"' href="?a=Page&d=edit&id={{page.id}}">{{page.title}}</a></strong><br/></td>
                           <td>{%if page.published%}Formal{%else%}Draft{%endif%}</td>
                           <td>
                               <a href="javascript:doDel({{page.id}})">Delete</a>
                           </td>
			</tr>
			{%endfor%}
			</tbody>
		</table>

   </div>
{% endblock  %}
{% block bscript %} 
<script type="text/javascript"> 
function doDel(id) {
 	$.ajax({
 		type: "GET",
 		url: "?a=Page&d=delete&id=" + id,
 		dataType: "json",
 		success: function(data){
 			var hmd = $("#hiddenMessage");
	    	if (data.type == "error") {
	    		hmd.html("<div class='error'>" + data.message + "</div>");
	    	} else {
	    		hmd.html("<div class='info'>" + data.message + "</div>");
	    	}
	    	hmd.show().focus();
	    	$("#page-" + id).hide();
 		}
 	});
}
</script> 
{% endblock %}